# Contributor: Alexander Belkov <msun00@yandex.ru>
# Maintainer: Alexander Belkov <msun00@yandex.ru>
pkgname=at
pkgver=3.2.1
pkgrel=1
pkgdesc="AT and batch delayed command scheduling utility and daemon"
url="http://blog.calhariz.com/index.php?tag/at"
arch="all"
options="!check suid"  # No test suite.
license="GPL-2.0-or-later"
makedepends="ssmtp flex-dev byacc"
install="$pkgname.pre-install"
subpackages="$pkgname-doc $pkgname-openrc"
source="http://software.calhariz.com/at/at_$pkgver.orig.tar.gz
	10-Makefile.in-1.patch
	at.allow
	atd.initd
	"

prepare() {
	default_prepare
	update_config_guess
}

build() {
	LEXLIB=-lfl \
	./configure \
		--prefix=/usr \
		--sbindir=/usr/sbin \
		--runstatedir=/var/run \
		--with-daemon_username=at \
		--with-daemon_groupname=at \
		--with-jobdir=/var/spool/atd \
		--with-atspool=/var/spool/atd
	make
}

package() {
	install -D -o root -g at -m 640 "$srcdir"/at.allow \
		"$pkgdir"/etc/at.allow
	make IROOT="$pkgdir" install
	install -m 755 -D "$srcdir"/atd.initd \
		"$pkgdir"/etc/init.d/atd
}

sha512sums="8109b2acf220ffc14ea78e7d5671507e8cad41a163c1d7f96de18aae05c8617071c6306e04446450190f492a65ca31f51ed040fba5719b67625a58f738fc9c9e  at_3.2.1.orig.tar.gz
ba57e93c9c90dc989e8ac299c12de13de0005b28fd934620a9a5b47af89db3c0dc63e39043ab3a50d313ed2bb4f4832b1f68db971b3f515c500a2b74ed18acbd  10-Makefile.in-1.patch
21e1bc024bd76c76b68e04614c6def5b03fd4b658e59bfde065b464b520f463711b795455e3a5c81a8a1946b2bca2f83d6c19300a4d3326ce17959a7cbc0846a  at.allow
fe5c075566ef1955e0eb4b4446fe1ea401940df6e0f29e4e2f1baf93e231214db58c707e99b16bb3a3c8c288a05fc390a44c6f09fde50d31f0ac631a98d86c2d  atd.initd"
